package cn.com.dycc.task_manage.orderdeal.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.com.dycc.common.controller.BaseController;
import cn.com.dycc.task_manage.orderdeal.entity.NewFindOrderDeal;
import cn.com.dycc.task_manage.orderdeal.param.FindOrdealineParam;
import cn.com.dycc.task_manage.orderdeal.param.ListAttachAndUserDept;
import cn.com.dycc.task_manage.orderdeal.param.NewOrderDealParam;
import cn.com.dycc.task_manage.orderdeal.service.OrderDealService;
import cn.com.dycc.task_manage.ordermain.entity.WorkOrdealInfor;
import cn.com.dycc.util.JsonObjectResult;

@Controller
@RequestMapping("deal")
public class OrderDealController extends BaseController{
	
	@Resource(name="orderDealService")
	private OrderDealService orderDealService;
	
	//查询工单细表信息
	@RequestMapping("/findordeal.do")
	@ResponseBody
	public JsonObjectResult findOrDealByUserId(HttpServletRequest request,FindOrdealineParam findOrdealineParam){
		List<WorkOrdealInfor> list = orderDealService.findOrDealByUserId(request, findOrdealineParam);
		String count = orderDealService.findOrDealByUserIdCount(request, findOrdealineParam);
		return new JsonObjectResult(count,list);
	}
	
	//查询未处理工单细表信息
	@RequestMapping("/findnotordeal.do")
	@ResponseBody
	public JsonObjectResult findOrDealNotByUserId(HttpServletRequest request,FindOrdealineParam findOrdealineParam){
		List<WorkOrdealInfor> list = orderDealService.findOrDealNotByUserId(request, findOrdealineParam);
		String count = orderDealService.findOrNotDealByUserIdCount(request, findOrdealineParam);
		return new JsonObjectResult(count,list);
	}
	
	//处理工单并且发送给下一节点
	@RequestMapping("/send.do")
	@ResponseBody
	public JsonObjectResult updateAndSend(HttpServletRequest request,@RequestBody ListAttachAndUserDept listAttachAndUserDept){
		String mes = orderDealService.updateAndSend(request,listAttachAndUserDept);
		return new JsonObjectResult(mes);
	}
	
	//查询已处理的工单信息2018-07-25新起接口
	@RequestMapping("/findnewordeal.do")
	@ResponseBody
	public JsonObjectResult newFindOrderDeal(HttpServletRequest request,NewOrderDealParam newOrderDealParam){
		List<NewFindOrderDeal> list = orderDealService.newFindOrderDeal(request, newOrderDealParam);
		String count = orderDealService.newFindOrderDealCount(request, newOrderDealParam);
		return new JsonObjectResult(count,list);
	}
}
